<% title("People") %>

<div class="grid_12">
  <div class="bottom-spacing">
    <div class="float-right">
      <%= link_to 'New Person', new_person_path, :class => 'cta cta-yellow', :title => "Create a new person" %>
    </div>
      <%= form_tag people_path, :method => 'get', :id => "people_search" do %>
      <%= hidden_field_tag :direction, params[:direction] %>
      <%= hidden_field_tag :sort, params[:sort] %>
      <%= hidden_field_tag :enabled_only, params[:enabled_only] %>
      <%= hidden_field_tag :disabled_only, params[:disabled_only] %>
      <p>
        Search:
        <%= text_field_tag :search, params[:search], :class => 'input-short' %>
        <%= submit_tag "Search", :name => nil, :class => "submit-green" %>
      </p>
    <% end %>
  </div>
  <div class="module">
    <h2><span><%= @people.offset_value + 1 %> - <%= @people.offset_value + @people.length %> of <%= @people.total_count %> People</span></h2>
    <div class="module-table-body">
      <table id="personTable" class="tablesorter">
        <thead>
          <tr>
            <%= sortable "last_name", "Name" %>
            <%= sortable "address" %>
            <%= sortable "status_id", "Status" %>
            <%= sortable "enabled" %>
            <th></th>
          </tr>
        </thead>
        <tbody>
          <% @people.each do |person| %>
          <tr class='<%= cycle("even", "odd") %>'>
            <td><%= link_to person.full_name, person, :title => "<span class='title'>View #{person.first_name} #{person.last_name}'s Details</span>" %></td>
            <td><%= person.full_address %></td>
            <td><%= person.person_status.name %></td>
            <td align="center"><%= person.enabled ? image_tag("icons/accept.png") : image_tag("icons/cancel.png") %></td>
            <td nowrap="nowrap" align="right">
              <%= unless person.phone.nil? or person.phone.empty? then link_to image_tag("icons/phone.png"), person, :title => "<span class='title'>#{person.first_name} #{person.last_name} Phone:</span><br/>#{person.phone}" end %>
              <%= unless person.email.nil? or person.email.empty? then mail_to person.email, image_tag("icons/email.png"), :title => "<span class='title'>Email #{person.first_name} #{person.last_name}</span> <br/>#{person.email}" end %>
              <%= unless person.note.nil? or person.note.empty? then link_to image_tag("icons/note.png"), person, :title => "<span class='title'>#{person.first_name} #{person.last_name} Notes:</span><br/>#{person.note}" end %>
           	  <%= link_to image_tag("icons/pencil.png"), edit_person_path(person), :title => "<span class='title'>Edit #{person.first_name} #{person.last_name}</span>" %>
              <%= link_to image_tag("icons/delete.png"), person, confirm: 'Are you sure you want to disable this person?', method: :delete, :title => "<span class='title'>Disable #{person.first_name} #{person.last_name}</span>" if person.enabled %>
            </td>
          </tr>
          <% end %>
        </tbody>
      </table>
      <div class="pager" id="pager">
        <span style="float:left; margin-top: 3px; padding-right: 10px;">Filters:</span>
        <%= all_filter %>
        <%= enabled_filter %>
        <%= disabled_filter %>
        <div style="clear: both"></div>
      </div>
    </div>
  </div>
  <%= paginate @people %>
</div>